<template>
	<view class="base-page">
		<view class="yangsf-padding-20">
			<u--form labelPosition="left" labelWidth="80" :model="complaint" :rules="rules" ref="uForm">
				<u-form-item label="投诉建议" prop="content" ref="item1">
					<u--textarea v-model="complaint.content" placeholder="投诉建议"></u--textarea>
				</u-form-item>
				<u-form-item>
					<u-button type="primary" text="提交" @click="save"></u-button>
				</u-form-item>
			</u--form>
		</view>
	</view>
</template>

<script>
	import { saveComplaint } from '@/config/api.js'
	export default {
		data() {
			return {
				complaint:{
					content: '',
					uuid: 'uuid'
				},
				rules:{
					content: [
						{
							type: 'string',
							required: true,
							message: '请填写内容',
							trigger: ['blur', 'change']
						},
						{
							type: 'string',
							min: 10,
							required: true,
							message: '不低于10个字',
							trigger: ['change']
						}
					],
				}
			}
		},
		methods: {
			save() {
				this.$refs.uForm.validate().then(res => {
					
					saveComplaint(this.complaint).then(res => {
						if(res.code == 200){
							uni.$u.toast('提交成功')
							setInterval(() => {
								uni.navigateBack()
							}, 2000);
						}
						else{
							uni.$u.toast('提交失败')
						}
					})
				}).catch(errors => {
					uni.$u.toast('校验失败')
				})
			
			},
		}
	}
</script>

<style>

</style>
